package rpc

import (
	"github.com/cloudwego/kitex/client"
	"github.com/cloudwego/kitex/pkg/rpcinfo"
	"github.com/kitex-contrib/obs-opentelemetry/tracing"
	"userrpc/rpc/user"
)

func Client() user.RPCClient {
	// 设置tracer provider
	//otelmod.TracerProviderInit("user-rpc-client")
	// 服务停止关闭tracer provider
	//defer otelmod.ProviderShutdown()

	opts := make([]client.Option, 0)

	opts = append(opts, client.WithHostPorts("localhost:4001"))
	opts = append(opts, client.WithSuite(tracing.NewClientSuite()))
	opts = append(opts, client.WithClientBasicInfo(&rpcinfo.EndpointBasicInfo{ServiceName: "user-rpc-client"}))
	tmp, err := user.NewRPCClient("user", opts...) // client.WithSuite(tracing.NewClientSuite()
	if err != nil {
		panic(err)
	}
	return tmp
}
